package com.hong.qrpc.strategy.client.config;

import com.hong.config.constant.ClientConfig;
import com.hong.qrpc.RpcClient;
import com.hong.qrpc.config.ConfigManager;
import com.hong.qrpc.strategy.PropertiesStrategy;
import com.hong.qrpc.utils.StringUtils;

import java.util.Map;

/**
 * @Author HQT
 * @Date 2022/7/17 14:42
 */
public class PortStrategy implements PropertiesStrategy {
    @Override
    public void disposeProperties(RpcClient rpcClient) {
        ConfigManager configManager = rpcClient.getConfigManager();
        Map<Object, Object> profile = configManager.getProfile();
        String port = (String) profile.get(ClientConfig.QRPC_CLIENT_PORT);
        if (!StringUtils.isEmpty(port)) {
            configManager.getRpcClientConfig().setPort(Integer.parseInt(port));
        }
    }
}
